/**
 * 
 */
package optimization.naturalOptimization.terminationCriterion;

import optimization.naturalOptimization.NaturalOptimization;

/**
 * This class provides a termination criterion in dependence on the standard
 * deviation of the individual results.
 * 
 * @author Kevin Wagner
 * @version 1.0
 */
public class StandardDeviationTermination extends TerminationCriterion {

	/**
	 * Creates a new Termination Criterion with a given parent optimization.
	 * 
	 * @param opt
	 *            parent optimization
	 */
	public StandardDeviationTermination(NaturalOptimization opt) {
		super(opt);
	}

	@Override
	public boolean isFinished() {
		double limit = getParentOptimization().getStandardDeviationLimit();
		double current = getParentOptimization().getResults().get(
				getParentOptimization().getCurrentGeneration())[3];
		if (current <= limit) {
			return true;
		}
		return false;
	}

	@Override
	public String getIndentification() {
		return "Standard Deviation Termination Criterion";
	}

}
